package com.ruoyi.tt.service;

import com.ruoyi.tt.domain.TtArticle;
import com.ruoyi.tt.mapper.TtArticleMapper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class ThreadService {
    private static  ExecutorService threadPool = Executors.newFixedThreadPool(5);
    //    @Async("taskExecutor1")
    public void updateViewCount(TtArticleMapper articleMapper, TtArticle article) {

        threadPool.execute(() -> {
            articleMapper.updateTtArticle(article); // 自增1
            System.out.println("Thread.currentThread().getName() = " + Thread.currentThread().getName());
        });
    }
}
